package com.hu.morser;

import org.ksoap2.serialization.SoapObject;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class DecodeTab extends Activity implements OnClickListener {
	private TextView output;
	private EditText decodingtext, seperatorsign;
	private Webservice webservice;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.decode);
		Button decode = (Button) findViewById(R.id.decoder);
		decode.setOnClickListener(this);
		output = (TextView) findViewById(R.id.output);
		decodingtext = (EditText) findViewById(R.id.textinput);
		seperatorsign = (EditText) findViewById(R.id.seperinput);
		webservice = new Webservice();
	}

	@Override
	public void onClick(View v) {
		SoapObject result = webservice.Decode(decodingtext.getText().toString(), seperatorsign.getText().toString());
		if(result != null)
		{
			String text = result.getPropertyAsString(0);
			output.setText(text);
		}
		else
			output.setText("something went wrong");
		
	}
	
}
